//
// Created by liushuai on 2020/2/11.
//
#include "rotate.h"
vector<int>& rotate(vector<int>&nums,int k){
    k%=nums.size();
    vector<int> temp(nums.end()-k,nums.end());
    int tail = nums.size()-k-1;
    for(int i=tail;i>=0;i--){
        nums.at(i+k) = nums.at(i);
    }
    for(int i=k-1;i>=0;i--){
        nums.at(i) = temp.at(i);
    }
    return nums;

}